package prefix_sum;

import java.util.Scanner;

public class Demo2_two_dimensional {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();
            int[][] nums = new int[n][m];
            long[][] tab = new long[n+1][m+1];
            for(int i = 0;i <n;i++) {
                for(int j = 0;j <m;j++) {
                    nums[i][j] = in.nextInt();
                }
            }

            for(int i = 1;i <=n;i++) {
                for(int j = 1;j <=m;j++) {
                    tab[i][j] = tab[i-1][j]+tab[i][j-1]+
                            nums[i-1][j-1]-tab[i-1][j-1];
                }
            }

            for(int i =0;i<q;i++) {
                int l1=in.nextInt();
                int l2 = in.nextInt();
                int r1 = in.nextInt();
                int r2 = in.nextInt();

                long num = tab[r1][r2]-tab[l1-1][r2]-tab[r1][l2-1]+tab[l1-1][l2-1];
                System.out.println(num);
            }

        }
    }
}
